package com.ruoyi.personnel.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.personnel.domain.Certificate;
import com.ruoyi.personnel.mapper.CertificateMapper;
import com.ruoyi.personnel.service.ICertificateService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 专科护士培训记录Service业务层处理
 *
 * @author ruoyi
 * @date 2021-02-26
 */
@Service
public class CertificateServiceImpl extends ServiceImpl<CertificateMapper, Certificate> implements ICertificateService {

    @Override
    public List<Certificate> queryList(Certificate certificate) {
        LambdaQueryWrapper<Certificate> lqw = Wrappers.lambdaQuery();
        if (StringUtils.isNotBlank(certificate.getName())){
            lqw.like(Certificate::getName ,certificate.getName());
        }
        if (StringUtils.isNotBlank(certificate.getJobNumber())){
            lqw.eq(Certificate::getJobNumber ,certificate.getJobNumber());
        }
        if (StringUtils.isNotBlank(certificate.getPersonnelId())){
            lqw.eq(Certificate::getPersonnelId ,certificate.getPersonnelId());
        }
        if (StringUtils.isNotBlank(certificate.getSpecialtyType())){
            lqw.eq(Certificate::getSpecialtyType ,certificate.getSpecialtyType());
        }
        if (StringUtils.isNotBlank(certificate.getUnit())){
            lqw.eq(Certificate::getUnit ,certificate.getUnit());
        }
        if (StringUtils.isNotBlank(certificate.getTrainingLocation())){
            lqw.eq(Certificate::getTrainingLocation ,certificate.getTrainingLocation());
        }
        if (StringUtils.isNotBlank(certificate.getCertificateType())){
            lqw.eq(Certificate::getCertificateType ,certificate.getCertificateType());
        }
        if (StringUtils.isNotBlank(certificate.getCertificateName())){
            lqw.like(Certificate::getCertificateName ,certificate.getCertificateName());
        }
        if (StringUtils.isNotBlank(certificate.getInitialUpdate())){
            lqw.eq(Certificate::getInitialUpdate ,certificate.getInitialUpdate());
        }
        if (StringUtils.isNotBlank(certificate.getStartTime())){
            lqw.eq(Certificate::getStartTime ,certificate.getStartTime());
        }
        if (StringUtils.isNotBlank(certificate.getDuration())){
            lqw.eq(Certificate::getDuration ,certificate.getDuration());
        }
        if (StringUtils.isNotBlank(certificate.getCertificateNo())){
            lqw.eq(Certificate::getCertificateNo ,certificate.getCertificateNo());
        }
        if (StringUtils.isNotBlank(certificate.getStatus())){
            lqw.eq(Certificate::getStatus ,certificate.getStatus());
        }
        return this.list(lqw);
    }
}
